package nodes.command;

import java.awt.Point;
import java.util.List;
import parser.ParserException;
import model.Model;
import model.Turtle;
import nodes.AbstractNode;
import nodes.ConstantNode;


/**
 * Moves the turtle to an absolute screen position
 */
public class HomeC extends AbstractCommand
{
    private static final Point HOME_POINT = new Point(0,0);
    
    public AbstractNode evaluate (List<AbstractNode> myArguments, Model model)
    {
        if (myArguments.size() != Integer.parseInt(resources.getString("home")))
        {
            throw ParserException.BAD_ARGUMENTS;
        }

        int numOfPixelsMoved = 0;
        for(Turtle currentTurtle : model.getActiveTurtles())
        {
            numOfPixelsMoved += currentTurtle.setLocation(HOME_POINT);
        }
        
        return new ConstantNode(numOfPixelsMoved) ;
    }
}
